<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
  String _id=request.getParameter("_");
%>

<div class="row">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading">
                <h3 class="panel-title">公告通知登记表</h3>
            </div>

            <div style="margin: 10px">

                <!-- Nav tabs -->
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#bsc-tab-1" data-toggle="tab">公告通知</a></li>
                    <c:if test="${notice.numStatus==1}"><li><a href="#bsc-tab-2" data-toggle="tab">浏览情况</a></li></c:if>
                </ul>

                <!-- Tabs Content -->
                <div class="tab-content">

                    <div class="tab-pane pad-btm fade in active" id="bsc-tab-1">
                        <!-- BASIC FORM ELEMENTS -->
                        <!--===================================================-->
                        <form id="form_notice_input" class="panel-body form-horizontal form-padding">

                            <input type="hidden" name="keyId" id="keyId" value="${notice.id}" />

                            <div class="form-group">
                                <label class="col-md-2 control-label">公告主题<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="text" id="subject" name="subject" class="form-control" disabled value="${notice.subject}">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">是否置顶<i class="fa fa-asterisk txt-color-red"></i>
                                </label>
                                <div class="col-md-6">
                                    <input type="text" id="isTop" name="isTop" class="form-control" disabled value=${notice.isTop==1?'是':'否'}>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">公告类型<i class="fa fa-asterisk txt-color-red"></i>
                                </label>
                                <div class="col-md-6">
                                    <input type="text" id="dictItem" name="dictItem" class="form-control" disabled value="${notice.name}">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">
                                    发布部门
                                    <i class="fa fa-asterisk txt-color-red"></i>
                                </label>
                                <div class="col-md-6">
                                    <input type="text" id="deptName" name="deptName" class="form-control" disabled value="${notice.issueDepartment.name}">
                                </div>
                            </div>

<c:if test="${notice.numStatus<1}">
                            <div class="form-group">
                                <label class="col-md-2 control-label">通知对象<i class="fa fa-asterisk txt-color-red"></i>
                                </label>
                                <div class="col-md-6">
                                    <input type="text" id="noticeType" name="noticeType" class="form-control" disabled value="${notice.noticeType}">
                                </div>
                            </div>

                            <div class="form-group" id="divNoticeDepts">
                                <label class="col-md-2 control-label">
                                    通知部门
                                    <i class="fa fa-asterisk txt-color-red"></i>
                                </label>
                                <div class="col-md-6">
                                    <input type="text" id="deptNames" name="deptNames" class="form-control" disabled
                                           value="<c:forEach var="item" items="${notice.noticeDepartments}" varStatus="status">${item.name}<c:if test="${!status.last}">,</c:if></c:forEach>">
                                </div>
                            </div>

                            <div class="form-group" id="divNoticeUsers">
                                <label class="col-md-2 control-label">
                                    通知个人
                                    <i class="fa fa-asterisk txt-color-red"></i>
                                </label>
                                <div class="col-md-6">
                                    <input type="text" id="userNames" name="userNames" class="form-control" disabled
                                           value="<c:forEach var="item" items="${notice.noticeUsers}" varStatus="status">${item.name}<c:if test="${!status.last}">,</c:if></c:forEach>">
                                </div>
                            </div>
</c:if>
                            <div class="form-group">
                                <label class="col-md-2 control-label">内容<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="text" id="content" name="content" class="form-control" disabled value="${notice.content}">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">附件上传</label>
                                <div class="col-md-6">
                                    <input name="hiddenFiles" id="hiddenFilesAttachment" type="hidden" value="${notice.fileAttachment}">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">发布人</label>
                                <div class="col-md-2">
                                    <p class="form-control-static">${notice.creater.name}</p>
                                </div>
                                <label class="col-md-2 control-label">发布日期</label>
                                <div class="col-md-2">
                                    <p class="form-control-static"><fmt:formatDate pattern="yyyy-MM-dd" value="${notice.dateApply}" /></p>
                                </div>
                            </div>
                        </form>
                        <!--===================================================-->
                        <!-- END BASIC FORM ELEMENTS -->

                    </div>

                    <div class="tab-pane fade" id="bsc-tab-2">
                        <div class="table-responsive" style="min-height: 530px;margin: 10px">
                            <table id="notice_read_table"></table>
                            <div id="notice_read_page"></div>
                        </div>
                    </div>

                </div>
            </div>

            <div class="panel-footer">
                <a class="btn btn-default" id="apply-re-common" href="javascript:void(0)">
                    <i class="fa fa-lg fa-mail-reply"></i> 返回视图
                </a>
                <c:if test="${notice.numStatus==0 && user.id==notice.creater.id}">
                    <a class="btn btn-warning" key="ajax_notice_edit" href="javascript:void(0);"><i class="fa fa-lg fa-edit"></i> 编辑表单 </a>
                </c:if>
            </div>
        </div>
    </div>
</div>

<script>

    // 附件显示
    readLoad({
        objId:"hiddenFilesAttachment",
        entityName:"fileAttachment",
        sourceId:"hiddenFilesAttachment"
    });

    //编辑
    $("a[key='ajax_notice_edit']").unbind("click").bind("click",function(){
        loadURL("<%=path%>/activiti/notice/edit/"+$("#keyId").val(),$('#page-content'));
    });

    //返回视图
    $("#apply-re-common").click(returnToHashUrl);

    // 加载完成后执行
    $(function(){
        var tmp = $("#noticeType").val();
        if(tmp == "1"){
            $("#divNoticeDepts").show();
            $("#divNoticeUsers").hide();
            $("#noticeType").val("部门");
        } else if(tmp=="2"){
            $("#divNoticeDepts").hide();
            $("#divNoticeUsers").show();
            $("#noticeType").val("个人");
        } else {
            $("#divNoticeDepts").hide();
            $("#divNoticeUsers").hide();
            $("#noticeType").val("全体员工");
        }

        init_grid_noticeread();
    })

    function init_grid_noticeread() {

        __init_jqgrid('notice_read_table', 'notice_read_page',
            '<%=path%>/activiti/noticeread/list?noticeId='+$("#keyId").val(),
            ['查看人', '查看日期', 'id'],
            [
                {name: 'reader', index: 'reader', width: 100, sortable: false, search: false},
                {name: 'createTime', index: 'createTime', width: 160, sortable: false, search: false},
                {name: 'id', index: 'id', width: 100, key: true, hidden: true, hidedlg: true}
            ],
            true,
            {
                autowidth: false,
                height: 500
            }
        );

    }
</script>




